import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/get_core.dart';
import 'package:smart_shoes/define/define_colors.dart';
import 'package:smart_shoes/router/app_router.dart';
import 'package:smart_shoes/tools/widget_tools.dart';

class AccountSettingPage extends StatefulWidget {
  const AccountSettingPage({super.key});

  @override
  State<AccountSettingPage> createState() => _AccountSettingPageState();
}

class _AccountSettingPageState extends State<AccountSettingPage> {
  @override
  Widget build(BuildContext context) {
    List<String> titles = ["用户昵称", "手机号", "微信号", "修改密码"];
    List<String> contents = ["王慧的妈妈", "13234938501", "去绑定", ""];
    return Scaffold(
      appBar: AppBar(title: WidgetTools().TextTitle("账号设置")),
      backgroundColor: CustomColors.backgroundColor,
      body: Column(
        children: [
          //头像
          GestureDetector(
            onTap: () {
              showModalBottomSheet(
                context: context,
                builder:
                    (context) => Container(
                      height: 200,
                      padding: EdgeInsets.all(16),
                      child: Column(
                        children: [
                          ListTile(
                            leading: Icon(Icons.camera_alt),
                            title: Text('相册'),
                            onTap: () {
                              Navigator.pop(context);
                              // 处理拍照逻辑
                            },
                          ),
                          ListTile(
                            leading: Icon(Icons.photo),
                            title: Text('拍照'),
                            onTap: () {
                              Navigator.pop(context);
                              // 处理相册选择逻辑
                            },
                          ),
                          // ListTile(
                          //   leading: Icon(Icons.cancel),
                          //   title: Text('取消'),
                          //   onTap: () => Navigator.pop(context),
                          // ),
                        ],
                      ),
                    ),
              );
            },
            child: Container(
              padding: EdgeInsets.all(16),
              height: 130,
              color: Colors.white,
              child: Column(
                children: [
                  Center(
                    child: Container(
                      // color: Colors.white,
                      width: 62,
                      height: 62,
                      clipBehavior: Clip.antiAlias,
                      decoration: const BoxDecoration(shape: BoxShape.circle),
                      child: Image.network(
                        'https://img1.baidu.com/it/u=3921589634,1084294548&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                  SizedBox(height: 15),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Text(
                        "修改头像",
                        style: TextStyle(
                          color: CustomColors.textColor,
                          fontSize: 12,
                        ),
                      ),
                      SizedBox(width: 5),
                      Image.asset(
                        "assets/images/fankui.png",
                        width: 12,
                        height: 12,
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),

          // Container(
          //   padding: EdgeInsets.all(16),
          //   height: 130,
          //   color: Colors.white,
          //   child: Column(
          //     children: [
          //       Center(
          //         child: Container(
          //           // color: Colors.white,
          //           width: 62,
          //           height: 62,
          //           clipBehavior: Clip.antiAlias,
          //           decoration: const BoxDecoration(shape: BoxShape.circle),
          //           child: Image.network(
          //             'https://img1.baidu.com/it/u=3921589634,1084294548&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
          //             fit: BoxFit.cover,
          //           ),
          //         ),
          //       ),
          //       SizedBox(height: 15),
          //       Row(
          //         mainAxisAlignment: MainAxisAlignment.center,
          //         crossAxisAlignment: CrossAxisAlignment.center,
          //         children: [
          //           Text(
          //             "修改头像",
          //             style: TextStyle(
          //               color: CustomColors.textColor,
          //               fontSize: 12,
          //             ),
          //           ),
          //           SizedBox(width: 5),
          //           Image.asset(
          //             "assets/images/fankui.png",
          //             width: 12,
          //             height: 12,
          //           ),
          //         ],
          //       ),
          //     ],
          //   ),
          // ),
          SizedBox(height: 8),
          //信息
          Container(
            height: 256,
            child: ListView.builder(
              padding: EdgeInsets.zero,
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              itemCount: titles.length,
              itemBuilder: (context, index) {
                final title = titles.elementAt(index);
                final content = contents[index];
                return _buildDeviceInfoItem(title, content);
              },
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildDeviceInfoItem(String title, String content) {
    return GestureDetector(
      onTap: _tapJumpPage(title),
      child: Container(
        color: Colors.white,
        height: 52,
        padding: const EdgeInsets.all(12),
        margin: const EdgeInsets.only(bottom: 1),
        child: Row(
          children: [
            Text(
              title,
              style: const TextStyle(
                fontSize: 13,
                color: CustomColors.textColor,
              ),
            ),
            Spacer(),

            Text(
              content,
              style: const TextStyle(
                fontSize: 13,
                color: CustomColors.textColor,
              ),
            ),
            SizedBox(width: 8),
            Image.asset("assets/images/jiantou-up.png"),
          ],
        ),
      ),
    );
  }

  _tapJumpPage(String title) {
    if (title == '用户昵称') {
      // Get.toNamed(AppRoutes.changeNicknamePage);
    }
  }
}
